import { useEffect } from "react";

export function useWebscoket({ user_id, server_id }, cb) {
    const ws = new WebSocket(`ws://124.221.74.149:8003/koa/ws?user_id=${user_id}&server_id=${server_id}`);
    useEffect(() => {
        ws.onopen = () => {
            console.log('服务器已经建立了链接');
            cb && cb(ws)
        }
    }, [])
}